package com.qf.springcloud.controller;

import com.sun.javafx.binding.StringFormatter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/air")
public class AirSearchController {

    @Value("${server.port}")
    private int port;

    @Value("${spring.application.name}")
    private String appName;

    @GetMapping("/search/test")
    public String test(){
        return "Hello Air Search!!" + port + ",服务名：" + appName;
    }




    @PostMapping("/search/test1")   //Feign有默认超时时间，默认为1s
    public String test1(Integer id, String name,String gender) throws InterruptedException {
        String result = String.format("key-value接收:     用户信息为: id = %s , 姓名为 name = %s ,性别为 %s",id,name,gender);
        return result;
    }

    @GetMapping("/search/test2/{brand}/{color}")
    public String test2(@PathVariable String brand, @PathVariable String color){
        String result = String.format("路径接收:     鞋子的品牌: %s , 颜色为: %s", brand, color);
        return result;
    }

    @PostMapping("/search/test3")
    public String test3(@RequestBody Map map){
        String result = String.format("JSON接收:      接收到JSON数据,数据为: %s", map.toString());
        return result;
    }













}
